home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / Enforce / Scripting / Script.txt < prev   
Text File  |  2000-05-08  |  11KB  |  567 lines

  1. //=================================================================
  2. //        MESSAGE FILES
  3. //=================================================================
  4.  
  5.     msgfile("text/enforce.msg" ,lang)
  6.  
  7. //=================================================================
  8. //        PROGRAMS
  9. //=================================================================
  10.  
  11. //-----------------------------------------------------------------
  12. //    PROTOTYPES FOR ENGINE API
  13. //-----------------------------------------------------------------
  14.     proto void Print(void var)
  15.     proto void Println(void var)
  16.     proto void PlayMap(string name)
  17.     proto void PlayAnim(string name)
  18. //    proto void ShowPicture(string name)
  19. //    proto void PlayMusic(string name)
  20. //    proto void StopMusic()
  21. //    proto void PlayTrack(int num)
  22. //    proto void Say(string text)
  23.     proto int Rand()
  24.  
  25.     // Light functions
  26.     proto void ChangeLight(int num,int intens)
  27.     //proto int AddDynamicLight(vector origin,int intens,int delay)
  28.  
  29.     // Sound functions
  30.     proto void InitSounds(int ambients)
  31.     proto void SetAmbient(string name,int idx)
  32.     proto void AddSound(string name,int pri,int flags,thing source)
  33.  
  34.     //cache object
  35.     proto void CacheObject(string name)
  36.  
  37.     //things
  38.     proto vector GetOrigin(thing th)
  39.     proto void SetOrigin(thing th,vector orig)
  40.     proto vector GetVelocity(thing th)
  41.     proto void SetVelocity(thing th,vector vel)
  42.     proto void SetFlags(thing th,int flag)
  43.     proto void ClearFlags(thing th,int flag)
  44.     proto int GetFlags(thing th)
  45.  
  46.     proto int CallTargetClients(thing th,thing actor)
  47.     proto int AddTriggerInsider(thing th,thing actor)
  48.  
  49.     //tobject
  50.     proto void SetFrameGroup(thing th,int n)
  51.  
  52.     //AI
  53.     proto void Walk(thing th)
  54.     proto void WalkTo(thing th,vector final)
  55.  
  56. //-----------------------------------------------------------------
  57. //    Internal things
  58. //-----------------------------------------------------------------
  59. class door
  60.     constant tkind  KIND_FUNC
  61.     
  62.     begin void Exception()
  63.         eventmask(%0000000010110000010)
  64.         door_i()
  65.     end
  66.  
  67. end
  68.  
  69. //-----------------------------------------------------------------
  70. class secretdoor
  71.     constant tkind KIND_FUNC
  72.  
  73.     begin void Exception()
  74.         eventmask(%0000000000110000010)
  75. //        secretdoor_i()
  76.     end
  77.  
  78. end
  79.  
  80. //-----------------------------------------------------------------
  81. class lift
  82.     constant tkind KIND_FUNC
  83.  
  84.     begin void Exception()
  85.         eventmask(%0000000010111000000)
  86.         lift_i()
  87.     end
  88.  
  89. end
  90.  
  91. //-----------------------------------------------------------------
  92. class button
  93.     constant tkind KIND_FUNC
  94.  
  95.     begin void Exception()
  96.         eventmask(%0000000010010000010)
  97.         button_i()
  98.     end
  99.  
  100. end
  101.  
  102. //-----------------------------------------------------------------
  103. class portalsource
  104.     constant tkind KIND_TRIGGER
  105.  
  106.     begin void Exception()
  107.         eventmask(%0000000000001000010)
  108.         //call all things connected to this portal
  109.         CallTargetClients(this,other)
  110.     end
  111.  
  112. end
  113.  
  114. //-----------------------------------------------------------------
  115. class portaldest
  116.     constant tkind KIND_NULL
  117.  
  118.     begin void Exception()
  119.         eventmask(%0000000000100000000)
  120.         //someone was sent thru portal
  121.         GetOrigin(this)
  122.         SetOrigin(other,GetOrigin)
  123.         
  124.         AddSound("sound/r_tele4.wav",20,SF_ONCE,this)
  125.     end
  126.  
  127. end
  128.  
  129. //-----------------------------------------------------------------
  130. class waypoint
  131.     constant tkind KIND_TRIGGER
  132.  
  133.     begin void Exception()
  134.         eventmask(%0000000000001000010)
  135. //        waypoint_i()
  136.     end
  137.  
  138. end
  139.  
  140. //-----------------------------------------------------------------
  141. class wall
  142.     constant tkind KIND_FUNC
  143.  
  144.     begin void Exception()
  145.         eventmask(%0000000000110000010)
  146. //        wall_i()
  147.     end
  148.  
  149. end
  150.  
  151. //-----------------------------------------------------------------
  152. class switch1
  153.     constant tkind KIND_TRIGGER
  154.  
  155.     begin void Exception()
  156.         eventmask(%0000000000001000010)
  157.         if event & EV_TOUCH
  158.             AddTriggerInsider(this,other)
  159.             if AddTriggerInsider = TRUE
  160.                 AddSound("sound/switch02.wav",10,SF_ONCE,this);
  161.             endif
  162.  
  163.             ClearFlags(this,TFL_ACTIVE)
  164.         endif
  165.     end
  166.  
  167. end
  168.  
  169. //-----------------------------------------------------------------
  170. class switch2
  171.     constant tkind KIND_TRIGGER
  172.  
  173.     begin void Exception()
  174.         eventmask(%0000000000001000010)
  175.         if event & EV_TOUCH
  176.             AddTriggerInsider(this,other)
  177.             if AddTriggerInsider = TRUE
  178.                 AddSound("sound/switch02.wav",10,SF_ONCE,this);
  179.             endif
  180.         endif
  181.     end
  182.  
  183. end
  184.  
  185. //-----------------------------------------------------------------
  186.     class secret
  187.         constant tkind KIND_TRIGGER
  188.  
  189.         begin void Exception()
  190.             eventmask(%0000000000001000010)
  191.     //        secret_i()
  192.         end
  193.  
  194.     end
  195.  
  196. //-----------------------------------------------------------------
  197.     class changemap
  198.         constant tkind KIND_TRIGGER
  199.  
  200.         begin void Exception()
  201.             eventmask(%0000000000001000010)
  202.     //        changemap_i()
  203.         end
  204.  
  205.     end
  206.  
  207. //-----------------------------------------------------------------
  208.     class wind
  209.         constant tkind KIND_TRIGGER
  210.  
  211.         begin void Exception()
  212.             eventmask(%0000000000001000010)
  213.     //        wind_i()
  214.         end
  215.  
  216.     end
  217.  
  218. //-----------------------------------------------------------------
  219.     class earthquake
  220.         constant tkind KIND_TRIGGER
  221.  
  222.         begin void Exception()
  223.             eventmask(%0000000000001000010)
  224.     //        earthquake_i()
  225.         end
  226.  
  227.     end
  228.  
  229. //-----------------------------------------------------------------
  230.     class light
  231.         constant tkind KIND_NULL
  232.  
  233.         begin void Exception()
  234.             eventmask(%0000000000100000000)
  235.             light_i()
  236.         end
  237.  
  238.     end
  239.  
  240. //-----------------------------------------------------------------
  241.     class world
  242.         constant tkind KIND_WORLD
  243.  
  244.         begin void Exception()
  245.             eventmask(%0000000000000000000)
  246.         end
  247.     end
  248.  
  249. //-----------------------------------------------------------------
  250.     class player
  251. //accept all events
  252.     constant tkind KIND_ACTOR
  253.  
  254.     object("obj/player.obj")
  255.  
  256.         framegrp(1)
  257.             frame("Wait_1" ,80 ,0)
  258.             frame("Wait_2" ,80 ,0)
  259.     
  260.         framegrp(2)
  261.             frame("Wait_2" ,100 ,0)
  262.             frame("Wait_2" ,30 ,0)
  263.             frame("Wait_3" ,30 ,0)
  264.             frame("Wait_4" ,30 ,0)
  265.             frame("Wait_5" ,100 ,0)
  266.             frame("Wait_5" ,30 ,0)
  267.             frame("Wait_4" ,30 ,0)
  268.             frame("Wait_3" ,30 ,0)
  269.             frame("Wait_1" ,30 ,0)
  270.  
  271.         framegrp(3)
  272.             frame("Walk_1" ,50 ,0)
  273.             frame("Walk_2" ,50 ,0)
  274.             frame("Walk_3" ,50 ,0)
  275.             frame("Walk_4" ,50 ,0)
  276.             frame("Walk_5" ,50 ,0)
  277.             frame("Walk_6" ,50 ,0)
  278.             frame("Walk_7" ,50 ,0)
  279.             frame("Walk_8" ,50 ,0)
  280.  
  281.         begin void Exception()
  282.             if event & EV_KEY
  283.                 AddSound("sound/sgun1.wav",20,SF_ONCE,this);
  284.                 return
  285.             endif
  286.  
  287. //    if event & EV_
  288. //        player_i()
  289.         end
  290.  
  291.     end
  292.  
  293. //-----------------------------------------------------------------
  294.     class monst_civil
  295.         constant tkind KIND_PERSON
  296.  
  297.         object("obj/civil.obj")
  298.  
  299.             framegrp(1)
  300.                 frame("Wait_1" ,80 ,0)
  301.                 frame("Wait_2" ,80 ,0)
  302.     
  303.             framegrp(2)
  304.                 frame("Wait_2" ,100 ,0)
  305.                 frame("Wait_2" ,30 ,0)
  306.                 frame("Wait_3" ,30 ,0)
  307.                 frame("Wait_4" ,30 ,0)
  308.                 frame("Wait_5" ,100 ,0)
  309.                 frame("Wait_5" ,30 ,0)
  310.                 frame("Wait_4" ,30 ,0)
  311.                 frame("Wait_3" ,30 ,0)
  312.                 frame("Wait_1" ,30 ,0)
  313.  
  314.             framegrp(3)
  315.                 frame("Walk_1" ,50 ,0)
  316.                 frame("Walk_2" ,50 ,0)
  317.                 frame("Walk_3" ,50 ,0)
  318.                 frame("Walk_4" ,50 ,0)
  319.                 frame("Walk_5" ,50 ,0)
  320.                 frame("Walk_6" ,50 ,0)
  321.                 frame("Walk_7" ,50 ,0)
  322.                 frame("Walk_8" ,50 ,0)
  323.  
  324.         begin void Exception()
  325.     //        civil_i()
  326.         end
  327.  
  328.     end
  329.  
  330. //-----------------------------------------------------------------
  331.     //global variables for light anims
  332.     declare int Time10
  333.     declare int Light10
  334.     declare int Inc02
  335.     declare int Light02
  336.  
  337. //-----------------------------------------------------------------
  338.     begin void newframe()
  339.  
  340.         declare int light
  341.         declare int rnd
  342.         declare int inc
  343.  
  344.     //anim lights
  345.  
  346.         Rand()
  347.  
  348.         let rnd = Rand & 255
  349.  
  350.         //style 10
  351.         let Time10 = Time10 - time
  352.         if Time10 < 0
  353.             if rnd > 127
  354.                 let Light10 = 255 - Light10
  355.                 ChangeLight(10,Light10)
  356.             endif
  357.             let Time10 = 15
  358.         endif
  359.         
  360.         //style 1
  361.         let light = rnd & 63
  362.         let light = light + 192
  363.  
  364.         if light < 200
  365.             let light = 200
  366.         endif
  367.  
  368.         ChangeLight(1,light)
  369.  
  370.         //style 2 & 5
  371.         let inc = Inc02 * time
  372.         let Light02 = Light02 + inc
  373.         
  374.         if Light02 < 0
  375.             let Light02 = 0
  376.             let Inc02 = 0 - Inc02
  377.         endif
  378.  
  379.         if Light02 > 255
  380.             let Light02 = 255
  381.             let Inc02 = 0 - Inc02
  382.         endif
  383.  
  384.         ChangeLight(2,Light02)
  385.         ChangeLight(5,Light02)
  386.  
  387.         newframe_i()
  388.     end
  389.  
  390. //-----------------------------------------------------------------
  391.     begin void postframe()
  392.         postframe_i()
  393.     end
  394.  
  395. //-----------------------------------------------------------------
  396.     begin void initmap()
  397.         initmap_i()
  398.     end
  399.  
  400. //-----------------------------------------------------------------
  401.     begin int Pokus(int parm1 ,int parm2)
  402.         declare int ret
  403.  
  404.         let ret = parm1 + parm2
  405.  
  406.         return(ret)
  407.     end
  408.  
  409. //-----------------------------------------------------------------
  410.     begin string Test(string name)
  411.     
  412.         PlayMap(name)
  413.  
  414.         return(name)
  415.     end
  416.  
  417.  
  418. //-----------------------------------------------------------------
  419.     class Trida
  420.         declare int member1
  421.         
  422.     //constructor
  423.         begin void Trida()
  424.             let member1 = 666
  425.         end
  426.  
  427.     //destructor
  428.         begin void ~Trida()
  429.             let member1 = 0
  430.             Println("Ooooh no, I'm dead :-(")
  431.         end
  432.  
  433.         begin int pfunc()
  434.             Println(member1)
  435.         end
  436.     end
  437.  
  438. //-----------------------------------------------------------------
  439. class Map
  440.     declare string path
  441.  
  442.     begin void Map()
  443.         let path = ""
  444.     end
  445.  
  446.     begin void ~Map()
  447.     end
  448.  
  449.     begin void Play(string map)
  450.         declare string name
  451.  
  452.         Println(path)
  453.         Println(map)
  454.  
  455.         let name = path + map
  456.  
  457.         Println(name)
  458.         PlayMap(name)
  459.     end
  460.  
  461. end
  462.  
  463. //-----------------------------------------------------------------
  464. //    Main function
  465. //-----------------------------------------------------------------
  466.     begin void main()
  467.  
  468.     declare string mpath
  469.     declare string map
  470.     declare string apath
  471.     declare string anim
  472.     
  473.     declare string pokus
  474.     declare string star
  475.  
  476.     declare int res
  477.     declare int p1
  478.     declare int p2
  479.     declare float p3
  480.     declare vector v
  481.  
  482.     declare Trida obj
  483.  
  484.     declare Map test
  485.  
  486.     let v = "1 1 1"
  487.  
  488.     // init light anims
  489.     let Time10 = 0
  490.     let Light10 = 0
  491.     let Inc02 = 4
  492.     let Light02 = 0
  493.  
  494.     // init paths
  495.     let mpath = "maps/"
  496.     let apath = "anims/"
  497.  
  498.     CacheObject("sound/pain1.wav")
  499.  
  500.     InitSounds(2)
  501.  
  502. // First map
  503.     SetAmbient("sound/wind2.wav",1)
  504.     SetAmbient("sound/comp1.wav",0)
  505.  
  506.     let map = mpath + "pokus.map"
  507.     PlayMap(map)
  508.  
  509.     let map = mpath + "base.map"
  510.     PlayMap(map)
  511.  
  512.     return
  513.  
  514.  
  515.  
  516.  
  517.     let test = new Map
  518.  
  519.     let test.path = "maps/"
  520.  
  521.     InitSounds(2)
  522.  
  523. // First map
  524.     SetAmbient("sound/wind2.wav",1)
  525.     SetAmbient("sound/comp1.wav",0)
  526.     test.Play("pokus.map")
  527.     delete test
  528.  
  529.     let obj = new Trida
  530.  
  531.     obj.pfunc()
  532.     Println(obj.member1)
  533.     let obj.member1 = 0
  534.  
  535.     obj.pfunc()
  536.  
  537.     delete obj
  538.  
  539.     return
  540.  
  541.  
  542.     let p1 = 2
  543.     let p2 = 3
  544.  
  545.     Pokus(p1 ,p2)
  546.  
  547.     let p1 = Pokus
  548.  
  549.     Println(p1)
  550.  
  551.     let p1 = 1
  552.     let star = "*"
  553.  
  554.     tag loop
  555.         if p1 = 10
  556.             goto out
  557.         endif
  558.         Println(star)
  559.         let star = star + "*"
  560.         let p1 = p1 + 1
  561.     goto loop
  562.  
  563.     tag out
  564.  
  565.     end
  566. //-----------------------------------------------------------------
  567.